Fix hiera.yaml write race in the pupmod spec_helper template - #91
Open
silug wants to merge 2 commits into
Open
Conversation
The config-level before(:all) hook rewrites spec/fixtures/hieradata/hiera.yaml with a truncating write before every top-level example group. Under `rake parallel_spec`, every worker runs this hook, and a catalogue compile in another worker that reads hiera.yaml inside the truncate-to-write window sees an empty hiera config and silently compiles without any custom hieradata. This is the confirmed root cause of the fleet-wide random hieradata-not-applied spec failures (ref simp#90) — not the set_hieradata global-state design originally suspected. Reproduced deterministically in pupmod-simp-simplib by rewriting hiera.yaml in a tight loop while running dlookup_spec (simp/pupmod-simp-simplib#362, fixed there by simp/pupmod-simp-simplib#363 with this same change). Write the file atomically instead: write to a PID-suffixed temp file in the same directory and rename it into place. Readers then always see a complete hiera.yaml. The temp file must be in the same directory -- rename(2) is only atomic within a filesystem. Ref simp#90 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
silug
force-pushed
the
fix/hiera-yaml-write-race
branch
from
August 20, 2026 16:29
25104bb to
fd3be0f
Compare
silug
marked this pull request as ready for review
August 20, 2026 16:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #90.
Every
parallel_specworker'sbefore(:all)hook truncate-rewrites the sharedspec/fixtures/hieradata/hiera.yaml; a catalogue compile in another worker during the truncation window sees an empty hiera config and silently drops all custom hieradata. That's the source of the fleet's random hieradata-not-applied spec failures (simp/pupmod-simp-simplib#362, simp/pupmod-simp-rsyslog#211, and the earlier freeradius/simp_options/tftpboot/gnome/ssh/sssd "flakes"). The fix writeshiera.yamlatomically (write to a pid-suffixed tempfile + rename).Validated on simp/pupmod-simp-simplib#363 (merged): the module with the highest observed flake rate, green with the fixed helper.
Rollout, per the usual convention, ships in the same PR: session config
20260820-spec-helper-race.yaml(nowlatest) — a blanketapply_puppet_rolesession, safe again since #42. Because the baseline was just re-asserted fleet-wide, each repo's diff is exactly the atomic-write hunk (verified by a local e2e apply against a real pupmod-simp-aide clone); simplib already carries the fix and will come outunchanged.Rebased onto main (post-#42, so the template base is current); the rendered non-simpkv template is byte-identical to simplib's validated in-repo copy. 215 rspec + 26 BoltSpec examples green; both EPP render branches are valid Ruby.
🤖 Generated with Claude Code